#pragma once

#include <vector>

#include "Entity.h"

#define TEST_1
//#define TEST_2
//#define TEST_3
//#define TEST_4
//#define TEST_5

// Container for all game entities
class EntitiesCore {
public:
	inline static EntitiesCore &instance () {
		static EntitiesCore core;
		return core;
	}

	inline EntitiesCore () {
		Entity ent;
		Pipeline trans;
		const fp32 inc_i = 5.f;
		const fp32 inc_j = 5.f;
#if defined(TEST_1)
		for (fp32 i = 0.f; i <= 10.f; i += inc_i) {
			for (fp32 j = 0.f; j <= 100.f; j += inc_j) {
				trans.translate(i, j, 20.f);
				ent.setXform(trans);
				internalAddEntity(ent);
			}
		}
#elif defined(TEST_2)
		for (int i = 0; i <= 10; i += 1/**2*10*/) {
			for (int j = 0; j <= 10; j += 1/**2*5*/) {
				trans.translate(5.f, i, j + 20.f);
				ent.setXform(trans);
				internalAddEntity(ent);
			}
		}
#elif defined(TEST_3)

#elif defined(TEST_4)

#elif defined(TEST_5)

#else
		verify(false);
#endif // TESTs
	}

	inline static const std::vector<Entity> &entities () { return instance()._entities; }
	inline static const std::vector<Entity> &dbg_entities () { return instance()._dbg_entities; }

	inline static void addEntity (const Entity &ent) { instance()._entities.push_back(ent); }
	inline static void addDbgEntity (const Entity &ent) { instance()._dbg_entities.push_back(ent); }

	inline static void onDbgEntitesProcessed () { instance()._dbg_entities.clear(); }

private:
	inline void internalAddEntity(const Entity &ent) { _entities.push_back(ent); }
	inline void internalAddDbgEntity(const Entity &ent) { _dbg_entities.push_back(ent); }

private:
	std::vector<Entity> _entities;
	std::vector<Entity> _dbg_entities;
};